package co.edu.usbcali.ai.ga;

import java.io.Serializable;


public class Individual implements Comparable<Individual>,Serializable  {
	
	private String id;
	private ICromosom cromosom;
	private int birthGeneration;
	private float evaluation;
	private int children=0;

	/* **********************************************
	 * CONSTRUCTORS
	 * **********************************************/
	
	public Individual(String p_id){
		id=p_id;
	}

	public Individual(String p_id,ICromosom p_cromosom){
		id=p_id;
		cromosom=p_cromosom;
	}
	
	/* **********************************************
	 * 
	 * **********************************************/
	
	public boolean isCrossableWith(Individual p_partner){
		return getCromosom().isCrossableWith(p_partner.getCromosom());
	}
	

	public String toString(){
		return "Id:"+id+";Cromosom:"+cromosom+";Eval:"+evaluation;
	}

	public int size(){
		return getCromosom().size();	
	}

	@Override
	public int compareTo(Individual o) {
		return Float.valueOf(getEvaluation()).compareTo(Float.valueOf(o.getEvaluation()));
	}

	/* **********************************************
	 * GETTERS AND SETTERS
	 * **********************************************/

	
	public int getBirthGeneration() {
		return birthGeneration;
	}
	public void setBirthGeneration(int birthGeneration) {
		this.birthGeneration = birthGeneration;
	}

	public ICromosom getCromosom() {
		return cromosom;
	}
	public void setCromosom(ICromosom cromosom) {
		this.cromosom = cromosom;
	}

	public int getChildren() {
		return children;
	}

	public void setChildren(int children) {
		this.children = children;
	}

	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}

	public void setEvaluation(float evaluation) {
		this.evaluation = evaluation;
	}

	public float getEvaluation() {
		return evaluation;
	}
	

}
